import { OmitType, PartialType, PickType } from '@nestjs/swagger';

import { Food } from '@/modules/app/entities';
import { IsNumber, IsOptional } from 'class-validator';

export class CreateFoodReqDto extends OmitType(Food, [
  'foodId',
  'createdAt',
  'updatedAt',
  'category',
]) {}

export class FoodListReqDto extends PartialType(
  PickType(Food, ['categoryId', 'tag']),
) {
  /**
   * 每页条数
   */
  @IsOptional()
  @IsNumber()
  pageSize: number;

  /**
   * 第几页
   */
  @IsOptional()
  @IsNumber()
  pageNo: number;
}

class FoodVo extends OmitType(Food, ['punchFoods']) {}

export class FoodResDto {
  /**
   * 总数
   */
  total: number;

  /**
   * 列表
   */
  list: FoodVo[];
}

export class UpdateFoodDto extends PartialType(
  OmitType(Food, ['createdAt', 'updatedAt', 'foodId']),
) {}
